<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>代理商添加</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../../layui/css/layui.css" media="all">
    <script src="../../layui/layui.js"></script>
    <script src="../../js/jquery-1.8.3.min.js"></script>
    <script src="../../js/env.js"></script>
    <script src="../../js/jQuery.md5.js"></script>
    <script>
        if (layui.sessionData('user').userInfo === undefined) {
            window.location.href = "../login.html"
        }
    </script>
</head>
<body>
<fieldset class="layui-elem-field layui-field-title">
    <legend id="aaa">代理商添加</legend>
</fieldset>
<div class="demoTable">
    <button type="button" class="layui-btn" style="margin-left: 10px;margin-bottom: 10px" onclick="javascript :history.back(-1)">返回</button>
</div>
<form action="" class="layui-form">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><i style="color:red">*</i>&nbsp;代理账号</label>
            <div class="layui-input-inline">
                <input name="account" lay-verify="required" placeholder="请输入代理账号" autocomplete="off" class="layui-input" id="account"
                       type="text">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><i style="color:red">*</i>&nbsp;密码</label>
            <div class="layui-input-inline">
                <input name="password" autocomplete="off" placeholder="请输入密码"  class="layui-input" id="password" type="password">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><i style="color:red">*</i>&nbsp;用户名</label>
            <div class="layui-input-inline">
                <input name="username" autocomplete="off" placeholder="请输入用户名"  class="layui-input" id="username" type="text">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-radius" type="button" onclick="submi()" lay-submit="" lay-filter=""
                    style="background-color: #0092EF;">立即提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
        </div>
    </div>
</form>

<script>

    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

    });


    function submi() {
        if ($("#account").val() == "") {
            layer.msg("请输入代理商账号！");
            return;
        }
        if ($("#password").val() == "") {
            layer.msg("请输入密码！");
            return;
        }
        if ($("#username").val() == "") {
            layer.msg("请输入用户名！");
            return;
        }

        var requestData = {
            "account": $("#account").val(),
            "username": $("#username").val(),
            "password": $.md5($("#account").val() + "*" + $("#password").val())
        };
        var responseData = MyAjax("POST", "/admin/agentUser/editAndAddAgentUser", requestData, getToken())
        if (responseData.code === 0) {
            //缓存用户登录信息
            // layui.sessionData('user', {
            //     key: 'userInfo'
            //     , value: responseData.data
            // });
            layer.msg("添加成功");
            setTimeout(function () {
                history.back(-1)
            }, 500)
        }


    }
</script>
</body>

</html>
